# -*-coding: Utf-8 -*-
# @File : celery_config .py
# author: Chimengmeng
# blog_url : https://www.cnblogs.com/dream-ze/
# Time：2024/7/3
# 参数配置文件celeryconfig.py

from datetime import timedelta
from celery.schedules import crontab
import os

REDIS_HOST = os.environ.get("REDIS_HOST")
REDIS_PROT = os.environ.get("REDIS_PORT")

BROKER_URL = f'redis://{REDIS_HOST}:{REDIS_PROT}/1'
CELERY_RESULT_BACKEND = F'redis://{REDIS_HOST}:{REDIS_PROT}/2'
CELERY_TIMEZONE = "Asia/shanghai"  # 默认UTC
CELERY_RESULT_SERIALIZER = 'msgpack'

# 导入指定的任务模块
CELERY_IMPORTS = (
    'celery_task.user_register_task',
)

# 设置定时任务
# CELERYBEAT_SCHEDULE = {
#     # 每过10秒执行以下task1.add的定时任务
#     'task1': {
#         'task': 'celery_app.task1.add',
#         'schedule': timedelta(seconds=10),
#         'args': (2, 8)
#     },
#     # 等到22点18分执行task2的multiply
#     'task2': {
#         'task': 'celery_app.task2.multiply',
#         'schedule': crontab(hour=22, minute=20),
#         'args': (4, 5)
#     }
# }
